package com.zu.commu.insertDataServlet;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.zu.commu.context.ServerContext;
import com.zu.commu.interf.Data;
import com.zu.commu.interf.saveData.SaveData;
import org.apache.log4j.Logger;

public class InsertData implements SaveData {
	private static String receiveUrl = ServerContext.toCenterURL;

	private static Logger log = Logger.getLogger(InsertData.class.getName());

	public void insertData(Data data) {
		XStream xstream = new XStream(new DomDriver());
		xstream.alias("data", Data.class);
		String xml = xstream.toXML(data);
		log.debug(xml);
		boolean flag = new PostDataRemote().post(xml, receiveUrl);

		if (!flag) {
			log.error("向中心业务系统发送数据失败!");
		}
	}
}
